home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmigaPlus / Tools / Development / envCPP31 / c++ / rexx / createproject.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2002-01-01  |  33.0 KB  |  1,067 lines

  1. /* rexx macro */
  2.  
  3. options results                             /* enable return codes     */
  4.  
  5. if (left(address(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  6.  
  7.     address 'GOLDED.1'
  8.  
  9. 'LOCK CURRENT RELEASE=4'                    /* lock GUI, gain access   */
  10.  
  11. if (RC ~= 0) then
  12.  
  13.     exit
  14.  
  15. options failat 6                            /* ignore warnings         */
  16.  
  17. signal on syntax                            /* ensure clean exit       */
  18.  
  19. /* ------------------------- INSERT YOUR CODE HERE: -------------------- */
  20.  
  21. /* INPUTS: ACTION/K/A,CMODE/K (supported values for CMODE: SAS-C,VBCC,GCC,STORMC,GENERIC) */
  22.  
  23. parse upper arg ACTION CMODE .
  24.  
  25. if (ACTION = "") then
  26.  
  27.     ACTION = "ASK"
  28.  
  29. if (CMODE = "") then
  30.  
  31.     CMODE = "GENERIC"
  32.  
  33. 'QUERY CAT'
  34.  
  35. if (RESULT = "deutsch") then do
  36.  
  37.     STRING.sNOTINSTALLED      = "Support für diesen Compiler wurde nicht|installiert:"
  38.     STRING.sCONFIGURATION     = "C/C++-Umgebung"
  39.     STRING.sNEWPROJECT        = "Neues Projekt"
  40.     STRING.sMENU              = "Neues Projekt anlegen oder ein|bestehendes Verzeichnis mit C-Quelltexten|übernehmen und unter die Kontrolle von|GNU make stellen (makefile hinzufügen) ?"
  41.     STRING.sNEWTAKEOVERCANCEL = "!Neues Projekt|_Makefile hinzufügen|Abbre_chen"
  42.     STRING.sNAME              = "Projektname"
  43.     STRING.sPROJECTNAME       = "Projektname auswählen (unter diesem Namen*nwird das ausführbare Programm erzeugt):"
  44.     STRING.sUNNAMED           = "unbenannt"
  45.     STRING.sBADNAME           = "Unerlaubte(s) Zeichen im Namen !"
  46.     STRING.sPROJECTFOLDER     = "Projektordner hier anlegen..."
  47.     STRING.sERROREXISTS       = "Ein Projekt mit diesem Namen existiert schon !"
  48.     STRING.sOPTIONSERR        = "Kann Compileroptionen nicht speichern !"
  49.     STRING.sEMPTYCREATED      = "Ein leeres Projekt wurde angelegt."
  50.     STRING.sSHOW              = "!Anzeigen|Makefile zeigen|Beenden"
  51.     STRING.sMAKEMAKEERROR     = "Makefile konnte nicht erzeugt werden !"
  52.     STRING.sTAKEOVER          = "Makefile hier erzeugen..."
  53.     STRING.sCONTROLLED        = "Das Verzeichnis bedindet sich schon unter|der Kontrolle eines GNU-Makefiles. Makefile|beibehalten oder ersetzen ?"
  54.     STRING.sKEEPREPLACE       = "!Beibehalten|_Ersetzen|Abbre_chen"
  55.     STRING.sSELECTHELP        = "Wählen Sie im folgenden Schritt die Quelltexte|aus, die zum Projekt gehören. Normalerweise sind|das alle Quelltexte im Verzeichnis (Kopf ALLE).||Hinweis: Zur Mehrfachauswahl die Umschalttaste|(SHIFT) beim Auswählen gedrückt halten !"
  56.     STRING.sSOURCES           = "Quelltexte auswählen..."
  57.     STRING.sREQUIRED          = "Es muss mindestens ein Quelltext in das|Projekt übernommen werden !"
  58.     STRING.sASSIMILATED       = "Das Projekt wurde übernommen und unter|die Kontrolle von GNU make gestellt."
  59.     STRING.sSHOWMAKEFILE      = "!Makefile zeigen|Beenden"
  60.     STRING.sCONFIGREADERR     = "Kann Konfiguration nicht lesen !"
  61.     STRING.sCONFIGHELP        = "Bevor das erste Projekt für Ihren Compiler*nerzeugt werden kann, müssen die compiler-*nspezifischen Einstellungen konfiguriert*nwerden.*n*nDie notwendigen Informationen finden Sie*nin der Dokumentation Ihres Compilers."
  62.     STRING.sCONTINUE          = "!Weiter...|Abbre_chen"
  63.     STRING.sCONTINUECOMPILER  = "!Mit Compilerauswahl fortfahren...|Abbre_chen"
  64.     STRING.sOTHER             = "Anderer Compiler"
  65.     STRING.sCOMPILERFOLDER    = "Geben Sie an, in welchem Verzeichnis*nsich die C/C++-Compilerumgebung befindet:"
  66.     STRING.sCOMPILERMISSING   = "Compiler nicht gefunden !"
  67.     STRING.sSTDHEADER         = "Geben Sie an, in welchem Verzeichnis sich die*nStandard-Header befinden (damit sind die mit*ndem Compiler gelieferten ISO-C-Header wie*nbeispielsweise <stdio.h> gemeint):"
  68.     STRING.sSTDHEADERMISSING  = "Standard-Header nicht gefunden !"
  69.     STRING.sNDKHEADER         = "Geben Sie an, in welchem Verzeichnis sich*ndie AmigaOS-Header befinden (die Angabe*nan dieser Stelle wird nur zum Verfolgen*nder Abhängigkeiten benutzt, nicht zum*nCompilieren):"
  70.     STRING.sNDKHEADERMNISSING = "AmigaOS3-Header nicht gefunden !"
  71.     STRING.sCOMPILE           = "Geben Sie an, mit welcher Befehlszeile ein*nQuelltext in eine Objektdatei (**.o) über-*nsetzt werden kann.*n*nIn der Befehlszeile können die Platzhalter*n%%src (stellvertretend für Name des Quell-*ntextes) und %%obj (stellvertretend für Name*nder Objektdatei) verwendet werden."
  72.     STRING.sLINK              = "Geben Sie an, mit welcher Befehlszeile die*nObjektdateien (**.o) zu einem ausführbaren*nProgramm gelinkt werden.*n*nIn der Befehlszeile können die Platzhalter*n%%objs (stellvertretend für die Namen der*nObjektdateien) und %%exe (stellvertretend*nfür den Namen des Programms) verwendet*nwerden."
  73.     STRING.sCONFIGSAVEERR     = "Kann Konfiguration nicht speichern !"
  74.     STRING.sCONFIGCREATED1    = "Die Konfigurationsdatei für die C/C++-Umgebung"
  75.     STRING.sCONFIGCREATED2    = "wurde erzeugt."
  76.     STRING.sOKEDIT            = "!Weiter|_Bearbeiten|Abbre_chen"
  77. end
  78. else do
  79.  
  80.     STRING.sNOTINSTALLED      = "Support für this compiler has not been|installed:"
  81.     STRING.sCONFIGURATION     = "C/C++ mode"
  82.     STRING.sNEWPROJECT        = "Create Project"
  83.     STRING.sMENU              = "Create a new project or put source codes|in an existing folder unter control of|GNU make (by adding a makefile) ?"
  84.     STRING.sNEWTAKEOVERCANCEL = "!New Project|_Add Makefile|_Cancel"
  85.     STRING.sNAME              = "Projektname"
  86.     STRING.sPROJECTNAME       = "Choose a project name (this will be used*nas name for the generated executable):"
  87.     STRING.sUNNAMED           = "unnamed"
  88.     STRING.sBADNAME           = "Illegal character(s) in name !"
  89.     STRING.sPROJECTFOLDER     = "Create project folder here..."
  90.     STRING.sERROREXISTS       = "A project with this name already exists !"
  91.     STRING.sOPTIONSERR        = "Can not save compiler options !"
  92.     STRING.sEMPTYCREATED      = "An empty project has been created."
  93.     STRING.sSHOW              = "!Edit|Show _makefile|_Done"
  94.     STRING.sMAKEMAKEERROR     = "Failed to generate a makefile !"
  95.     STRING.sTAKEOVER          = "Add makefile here..."
  96.     STRING.sCONTROLLED        = "This project folder is already controlled by|a makefile. Do you want to keep the existing|makefile or should it be replaced ?"
  97.     STRING.sKEEPREPLACE       = "!Keep|_Replace|_Cancel"
  98.     STRING.sSELECTHELP        = "In the next step you will select the source|codes that belong to this project. Typically|that includes all source codes in the project|folder (simply click the the ALL button in|that case).||Note: SHIFT-click to select multiple files !"
  99.     STRING.sSOURCES           = "Select source codes..."
  100.     STRING.sREQUIRED          = "You must specify at least one source|code as part of this project !"
  101.     STRING.sASSIMILATED       = "The project has been put under GNU|makefile control."
  102.     STRING.sSHOWMAKEFILE      = "!Show Makefile|_Done"
  103.     STRING.sCONFIGREADERR     = "Can not read configuration !"
  104.     STRING.sCONFIGHELP        = "Before the first project can be created*nfor your compiler setup, some compiler-*nspecific options must be configured.*n*nYou can find the information required for*nconfiguration in the documention of your*ncompiler."
  105.     STRING.sCONTINUE          = "!Continue...|_Cancel"
  106.     STRING.sCONTINUECOMPILER  = "!Continue with compiler selection|_Cancel"
  107.     STRING.sOTHER             = "Other Compiler"
  108.     STRING.sCOMPILERFOLDER    = "Where is your C/C++ development package located ?"
  109.     STRING.sCOMPILERMISSING   = "Compiler not found !"
  110.     STRING.sSTDHEADER         = "Specify where the standard header files are*nlocated on your computer (this refers to the*nISO C header files shipped with your compiler,*nfor example <stdio.h>):"
  111.     STRING.sSTDHEADERMISSING  = "Header files not found !"
  112.     STRING.sNDKHEADER         = "Specify where the AmigaOS header files*nare located on your computer (the*ninformation entered here is used to check*ndependencies, not for compilation):"
  113.     STRING.sNDKHEADERMNISSING = "AmigaOS3 header not found !"
  114.     STRING.sCOMPILE           = "Specify the command line to be used for*ncompiling a source code into an object*nfile (**.o).*n*nThe command line specified here must be*nsuitable for appending (1) the object name*nand (2) the source code name in order to*ngenerate the compilation command.*n"
  115.     STRING.sLINK              = "Specify the command line to be used for*nlinking a list of object files (*.o) into*nan executable.*n*nThe command line specified here must be*nsuitable for appending (1) the executable*nname and (2) the object names in order to*ngenerate the link command.*n"
  116.     STRING.sCONFIGSAVEERR     = "Can not save configuration !"
  117.     STRING.sCONFIGCREATED1    = "Configuration file for C/C++ environment"
  118.     STRING.sCONFIGCREATED2    = "has been created."
  119.     STRING.sOKEDIT            = "!Continue|_Edit|_Cancel"
  120. end
  121.  
  122. call readcfg(CMODE)
  123.  
  124. if (ACTION = "ASK") then do
  125.  
  126.     'REQUEST VAR=ACTION TITLE="' || STRING.sCONFIGURATION || ' «' || CMODE || '»" BODY="' || STRING.sMENU || '" BUTTON="' || STRING.sNEWTAKEOVERCANCEL || '"'
  127.  
  128.     if (RESULT = 1) then do
  129.  
  130.         ACTION = "NEW"
  131.     end
  132.     else if (RESULT = 2) then do
  133.  
  134.         ACTION = "MAKEMAKE"
  135.     end
  136.     else do
  137.  
  138.         'UNLOCK'
  139.  
  140.         exit
  141.     end
  142. end
  143.  
  144. /* create a new project ? */
  145.  
  146. if (ACTION = "NEW") then do
  147.  
  148.     PROJECTNAME = ""
  149.  
  150.     do until (PROJECTNAME ~= "")
  151.  
  152.         'REQUEST STRING TITLE="' || STRING.sNEWPROJECT || '" BODY="' || STRING.sPROJECTNAME || '" OLD="' || STRING.sUNNAMED || '" VAR=PROJECTNAME'
  153.  
  154.         if ((PROJECTNAME ~= "") & (RC = 0)) then do
  155.  
  156.             if ((INDEX(PROJECTNAME, "/") ~= 0) | (INDEX(PROJECTNAME, "\") ~= 0) | (INDEX(PROJECTNAME, ":") ~= 0)) then do
  157.  
  158.                 'REQUEST PROBLEM="' || STRING.sBADNAME || '"'
  159.  
  160.                 PROJECTNAME = ""
  161.             end
  162.         end
  163.         else do
  164.  
  165.             'UNLOCK'
  166.  
  167.             exit
  168.         end
  169.     end
  170.  
  171.     PATH = ""
  172.  
  173.     do until PATH ~= ""
  174.  
  175.         'REQUEST DIR SAVE TITLE="' || STRING.sPROJECTFOLDER || '" PATH="sys:" VAR=PATH'
  176.  
  177.         if ((RESULT ~= 0) & (RC = 0)) then do
  178.  
  179.             'EXPAND NAME="' || PATH || '" VAR=PATH'
  180.  
  181.             PATH = PATH || PROJECTNAME
  182.  
  183.             if (exists(PATH)) then do
  184.  
  185.                 'REQUEST PROBLEM="' || STRING.sERROREXISTS || '"'
  186.  
  187.                 PATH = ""
  188.             end
  189.         end
  190.         else do
  191.  
  192.             'UNLOCK'
  193.  
  194.             exit
  195.         end
  196.     end
  197.  
  198.     /* create project folder */
  199.  
  200.     'FILE NEWDIR NAME="' || PATH || '"'
  201.  
  202.     if (RC = 0) then do
  203.  
  204.         R = pragma('D', PATH)
  205.  
  206.         /* create folders for objects and executable */
  207.  
  208.         'EXPAND NAME="' || PATH || '" VAR=PATH'
  209.  
  210.         'FILE NEWDIR NAME="' || PATH || 'bin"'
  211.  
  212.         if (RC = 0) then do
  213.  
  214.             PROJECTNAME = "bin/" || PROJECTNAME
  215.  
  216.             'FILE NEWDIR NAME="' || PATH || 'o"'
  217.  
  218.             if (RC = 0) then do
  219.  
  220.                 OBJFOLDER = "o/"
  221.  
  222.                 shell
  223.  
  224.                 'copy "golded:add-ons/c++/samples/empty/main.c" main.c'
  225.  
  226.                 'golded:add-ons/c++/tools/makemake/bin/makemake >makefile COMPILE="' || CONFIG.CFG_COMPILE || '" LINK="' || CONFIG.CFG_LINK || '" LOCAL RECURSELOCAL CONTINUE EXECUTABLE="' || PROJECTNAME || '" OBJECTS INCLUDE="' || CONFIG.CFG_INCLUDE || '" SDK="' || CONFIG.CFG_NDK || '" PREFIX="' || OBJFOLDER || '" FILES "main.c"'
  227.  
  228.                 shell
  229.  
  230.                 if (exists("makefile")) then do
  231.  
  232.                     /* create default options file */
  233.  
  234.                     call saveoptions(CONFIG.CFG_SOFTWARE)
  235.  
  236.                     /* load created source code */
  237.  
  238.                     'REQUEST BODY="' || STRING.sEMPTYCREATED || '" BUTTON="' || STRING.sSHOW || '"'
  239.  
  240.                     if ((RESULT ~= 0) & (RC = 0)) then do
  241.  
  242.                         if (RESULT = 1) then
  243.  
  244.                             'OPEN NEW SMART NAME="' || PATH || '/main.c"'
  245.  
  246.                         if (RESULT = 2) then
  247.  
  248.                             'OPEN NEW SMART NAME="' || PATH || '/makefile"'
  249.                     end
  250.                 end
  251.                 else
  252.                     'REQUEST PROBLEM="' || STRING.sMAKEMAKEERROR || '"'
  253.             end
  254.         end
  255.     end
  256. end
  257.  
  258. /* add makefile to a folder ? */
  259.  
  260. if (ACTION = "MAKEMAKE") then do
  261.  
  262.     'REQUEST DIR TITLE="' || STRING.sTAKEOVER || '" VAR=PATH'
  263.  
  264.     if ((PATH ~= "") & (RC = 0)) then do
  265.  
  266.         'EXPAND NAME="' || PATH || '" VAR=PATH'
  267.  
  268.         if (exists(PATH || "makefile")) then do
  269.  
  270.             'REQUEST BODY="' || STRING.sCONTROLLED || '" BUTTON="' || STRING.sKEEPREPLACE || '"'
  271.  
  272.             if ((RESULT ~= "2") | (RC ~= 0)) then do
  273.  
  274.                 'UNLOCK'
  275.  
  276.                 exit
  277.             end
  278.         end
  279.  
  280.         R = pragma('D', PATH)
  281.  
  282.         /* select sources to be put under control of makefile */
  283.  
  284.         'REQUEST BODY="' || STRING.sSELECTHELP || '" BUTTON="' || STRING.sCONTINUE || '"'
  285.  
  286.         if ((RESULT = 0) | (RC ~= 0)) then do
  287.  
  288.             'UNLOCK'
  289.  
  290.             exit
  291.         end
  292.  
  293.         FILES = ""
  294.  
  295.         do until FILES ~= ""
  296.  
  297.             'REQUEST FILES PATTERN="#?.(c|cc|cpp|ccp|c++|a|asm|ass|i|s)" PATH="' || PATH || '" TITLE="' || STRING.sSOURCES || '" VAR=FILES'
  298.  
  299.             if (FILES = "") then
  300.  
  301.                 'REQUEST PROBLEM="' || STRING.sREQUIRED || '"'
  302.  
  303.             if (RC ~= 0) then do
  304.  
  305.                 'UNLOCK'
  306.  
  307.                 exit
  308.             end
  309.  
  310.         end
  311.  
  312.         /* process list of files: '"path/file" "path/file" ...' */
  313.  
  314.         MODULES = ""
  315.  
  316.         POS = 1
  317.         MAX = length(FILES)
  318.  
  319.         do while (POS <= MAX)
  320.  
  321.             do while ((substr(FILES, pos, 1) = " ") | (substr(FILES, pos, 1) = '"'))
  322.  
  323.                 POS = POS + 1
  324.  
  325.                 if (POS > MAX) then
  326.  
  327.                     leave
  328.             end
  329.  
  330.             START = POS
  331.             LEN   = 0
  332.  
  333.             do while (POS <= MAX)
  334.  
  335.                 DATA = substr(FILES, POS, 1)
  336.  
  337.                 if ((DATA = ':') | (DATA = '/')) then do
  338.  
  339.                     START = POS + 1
  340.                     POS   = POS + 1
  341.                     LEN   = 0
  342.                 end
  343.                 else if (DATA = '"') then do
  344.  
  345.                     leave
  346.                 end
  347.                 else do
  348.  
  349.                     LEN = LEN + 1
  350.                     POS = POS + 1
  351.                 end
  352.             end
  353.  
  354.             if (LEN ~= 0) then do
  355.  
  356.                 FULLPATH = substr(FILES, START, LEN)
  357.  
  358.                 if (FILEPART = index(FULLPATH, ":")) then
  359.  
  360.                     FULLPATH = substr(FULLPATH, FILEPART + 1)
  361.  
  362.                 do while (FILEPART = index(FULLPATH, "/"))
  363.  
  364.                     FULLPATH = substr(FULLPATH, FILEPART + 1)
  365.                 end
  366.  
  367.                 if (MODULES == "") then
  368.                     MODULES = FULLPATH
  369.                 else
  370.                     MODULES = MODULES || " " || FULLPATH
  371.             end
  372.         end
  373.  
  374.         /* try to locate executable name */
  375.  
  376.         call getprojectname("")
  377.  
  378.         if (PROJECTNAME = "") then do
  379.  
  380.             do until (PROJECTNAME ~= "")
  381.  
  382.                 'REQUEST STRING TITLE="' || STRING.sNAME || '" BODY="' || STRING.sPROJECTNAME || '" OLD="' || STRING.sUNNAMED || '" VAR=PROJECTNAME'
  383.  
  384.                 if ((PROJECTNAME = "") | (RC ~= 0)) then do
  385.  
  386.                     'UNLOCK'
  387.  
  388.                     exit
  389.                 end
  390.             end
  391.         end
  392.  
  393.         /* generate makefile */
  394.  
  395.         COMMANDLINE = 'golded:add-ons/c++/tools/makemake/bin/makemake >makefile VERBOSE COMPILE="' || CONFIG.CFG_COMPILE || '" LINK="' || CONFIG.CFG_LINK || '" LOCAL RECURSELOCAL CONTINUE EXECUTABLE="' || PROJECTNAME || '" OBJECTS INCLUDE="' || CONFIG.CFG_INCLUDE || '" SDK="' || CONFIG.CFG_NDK || '" PREFIX="' || OBJFOLDER || '" FILES ' || MODULES
  396.  
  397.         'FIX VAR=COMMANDLINE'
  398.  
  399.         'RUN CMD="' || COMMANDLINE || '" DIR="' || PATH || '" SHANGHAI=10'
  400.  
  401.         if (exists("makefile")) then do
  402.  
  403.             if (OBJFOLDER = "o/") then
  404.  
  405.                 'FILE NEWDIR NAME="' || PATH || 'o"'
  406.  
  407.             call saveoptions(CONFIG.CFG_SOFTWARE)
  408.  
  409.             if ((RESULT ~= 0) & (RC = 0)) then do
  410.  
  411.                 if (RESULT = 1) then
  412.  
  413.                     'OPEN NEW SMART NAME="' || PATH || '/makefile"'
  414.             end
  415.         end
  416.         else
  417.             'REQUEST PROBLEM="' || STRING.sMAKEMAKEERROR || '"'
  418.     end
  419. end
  420.  
  421. /* ---------------------------- END OF YOUR CODE ----------------------- */
  422.  
  423. 'UNLOCK' /* VERY important: unlock GUI */
  424. EXIT
  425.  
  426. SYNTAX:
  427.  
  428. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  429. 'UNLOCK'
  430. EXIT
  431.  
  432. /* /// "getprojectname" */
  433.  
  434. getprojectname: procedure expose CONFIG. STRING. PROJECTNAME OBJFOLDER
  435.  
  436.     parse upper arg SOFTWARE
  437.  
  438.     /* try to read project name from options file or makefile */
  439.  
  440.     PROJECTNAME = ""
  441.     OBJFOLDER   = ""
  442.  
  443.     call readoptions(SOFTWARE)
  444.  
  445.     if (PROJECTNAME = "") then do
  446.  
  447.         call readmakefile(SOFTWARE)
  448.  
  449.         if (PROJECTNAME = "") then do
  450.  
  451.             if (SOFTWARE ~= "") then do
  452.  
  453.                 /* try again but ignore specified compiler */
  454.  
  455.                 call readoptions("")
  456.  
  457.                 if (PROJECTNAME = "") then
  458.  
  459.                     call readmakefile("")
  460.             end
  461.         end
  462.     end
  463.  
  464.     return
  465.  
  466. /* /// */
  467. /* /// "readcfg" */
  468.  
  469. readcfg: procedure expose CONFIG. STRING.
  470.  
  471.     parse upper arg CMODE
  472.  
  473.     if (exists("golded:add-ons/c++/compilers/" || CMODE)) then do
  474.  
  475.         CONFIG.CFG_CONFIG          = "golded:add-ons/c++/compilers/" || CMODE || "/makemake.config"
  476.         CONFIG.CFG_SOFTWARE        = "generic"
  477.         CONFIG.CFG_COMPILERFOLDER  = ""
  478.         CONFIG.CFG_INCLUDE         = ""
  479.         CONFIG.CFG_NDK             = ""
  480.         CONFIG.CFG_COMPILE         = ""
  481.         CONFIG.CFG_LINK            = ""
  482.  
  483.         /* find configuration file */
  484.  
  485.         if (exists(CONFIG.CFG_CONFIG) ~= 0) then do
  486.  
  487.             /* read project configuration */
  488.  
  489.             R = open('CONFIG', CONFIG.CFG_CONFIG, 'READ')
  490.  
  491.             if (R = 0) then do
  492.  
  493.                 'REQUEST PROBLEM="' || STRING.sCONFIGREADERR || '"'
  494.             end
  495.             else do
  496.  
  497.                 do forever
  498.  
  499.                     DATA = readln('CONFIG')
  500.  
  501.                     if (eof('CONFIG')) then do
  502.  
  503.                         R = close('CONFIG')
  504.  
  505.                         leave
  506.                     end
  507.                     else do
  508.  
  509.                         if (left(DATA, 10) = "[SOFTWARE]") then
  510.  
  511.                             CONFIG.CFG_SOFTWARE = readln('CONFIG')
  512.  
  513.                         if (left(DATA, 16) = "[COMPILERFOLDER]") then
  514.  
  515.                             CONFIG.CFG_COMPILERFOLDER = readln('CONFIG')
  516.  
  517.                         if (left(DATA, 9) = "[INCLUDE]") then
  518.  
  519.                             CONFIG.CFG_INCLUDE = readln('CONFIG')
  520.  
  521.                         if (left(DATA, 5) = "[NDK]") then
  522.  
  523.                             CONFIG.CFG_NDK = readln('CONFIG')
  524.  
  525.                         if (left(DATA, 9) = "[COMPILE]") then
  526.  
  527.                             CONFIG.CFG_COMPILE = readln('CONFIG')
  528.  
  529.                         if (left(DATA, 6) = "[LINK]") then
  530.  
  531.                             CONFIG.CFG_LINK = readln('CONFIG')
  532.                     end
  533.                 end
  534.             end
  535.         end
  536.         else do
  537.  
  538.             /* welcome message */
  539.  
  540.             if (CMODE ~= "GENERIC") then
  541.  
  542.                 STRING.sCONTINUECOMPILER = STRING.sCONTINUE
  543.  
  544.             'REQUEST TITLE="' || STRING.sCONFIGURATION || ' «' || CMODE || '»"  BODY="' || STRING.sCONFIGHELP || '" BUTTON="' || STRING.sCONTINUECOMPILER || '"'
  545.  
  546.             if ((RESULT ~= 0) & (RC = 0)) then do
  547.  
  548.                 /* query compiler software */
  549.  
  550.                 if (CMODE = "SAS-C") then
  551.  
  552.                     SOFTWARE = "SAS/C"
  553.  
  554.                 else if (CMODE = "VBCC") then
  555.  
  556.                     SOFTWARE = "vbcc"
  557.  
  558.                 else if (CMODE = "GCC") then
  559.  
  560.                     SOFTWARE = "gcc"
  561.  
  562.                 else if (CMODE = "StormC") then
  563.  
  564.                     SOFTWARE = "StormC"
  565.  
  566.                 else do
  567.  
  568.                     'REQLIST VAR=SOFTWARE "SAS/C" "vbcc" "gcc" "DiceC" "StormC" "' || STRING.sOTHER || '"'
  569.  
  570.                     if ((SOFTWARE = "") | (RC ~= 0)) then do
  571.  
  572.                         'UNLOCK'
  573.  
  574.                         exit
  575.                     end
  576.                 end
  577.  
  578.                 /* choose defaults */
  579.  
  580.                 SUGGEST_COMPILERFOLDER     = 'sys:'
  581.                 SUGGEST_COMPILE            = '<compiler> -<donotlink> %src -<outfile> %obj'
  582.                 SUGGEST_LINK               = '<compiler> %objs -<outfile> %exe'
  583.                 SUGGEST_INCLUDE            = ''
  584.  
  585.                 if (SOFTWARE = "vbcc") then do
  586.  
  587.                     CONFIG.CFG_SOFTWARE = "VBCC"
  588.  
  589.                     SUGGEST_COMPILERFOLDER = 'vbcc:'
  590.                     SUGGEST_COMPILE        = 'vbcc:bin/vc $(shell vbccprefs) -c -o %obj %src'
  591.                     SUGGEST_LINK           = 'vbcc:bin/vc $(shell vbccprefs) -o %exe %objs'
  592.                     SUGGEST_INCLUDE        = 'vincludem68k:'
  593.                 end
  594.                 else if (SOFTWARE = "gcc") then do
  595.  
  596.                     CONFIG.CFG_SOFTWARE = "GCC"
  597.  
  598.                     SUGGEST_COMPILERFOLDER = 'GG:'
  599.                     SUGGEST_COMPILE        = 'gcc $(shell gccprefs) -c -o %obj %src'
  600.                     SUGGEST_LINK           = 'gcc $(shell gccprefs) -o %exe %objs'
  601.                     SUGGEST_INCLUDE        = 'gg:include'
  602.                 end
  603.                 else if (SOFTWARE = "SAS/C") then do
  604.  
  605.                     CONFIG.CFG_SOFTWARE = "SAS/C"
  606.  
  607.                     SUGGEST_COMPILERFOLDER = 'sc:'
  608.                     SUGGEST_COMPILE        = 'sc:c/sc nolink %src'
  609.                     SUGGEST_LINK           = 'sc:c/sc link %objs'
  610.                 end
  611.                 else if (SOFTWARE = "DiceC") then do
  612.  
  613.                     CONFIG.CFG_SOFTWARE = "DICE"
  614.  
  615.                     SUGGEST_COMPILERFOLDER = 'dcc:'
  616.                     SUGGEST_COMPILE        = 'dcc:bin/dcc -2.0 -// -c %src -o %obj'
  617.                     SUGGEST_LINK           = 'dcc:bin/dcc -2.0 -// -o %exe %objs'
  618.                     SUGGEST_INCLUDE        = 'dinclude:'
  619.                 end
  620.                 else if (SOFTWARE = "StormC") then do
  621.  
  622.                     CONFIG.CFG_SOFTWARE = "STORMC"
  623.  
  624.                     SUGGEST_COMPILERFOLDER = "stormc:"
  625.                 end
  626.                 else
  627.                     CONFIG.CFG_SOFTWARE = "GENERIC"
  628.  
  629.                 /* locate compiler */
  630.  
  631.                 do until CONFIG.CFG_COMPILERFOLDER ~= ""
  632.  
  633.                     'REQUEST STRING BODY="' || STRING.sCOMPILERFOLDER || '" OLD="' || SUGGEST_COMPILERFOLDER || '" VAR=CONFIG.CFG_COMPILERFOLDER'
  634.  
  635.                     if ((CONFIG.CFG_COMPILERFOLDER ~= "") & (RC = 0)) then do
  636.  
  637.                         if (exists(CONFIG.CFG_COMPILERFOLDER) = 0) then do
  638.  
  639.                             'REQUEST PROBLEM="' || STRING.sCOMPILERMISSING || '"'
  640.  
  641.                             CONFIG.CFG_COMPILERFOLDER = ""
  642.                         end
  643.                     end
  644.                     else do
  645.  
  646.                         'UNLOCK'
  647.  
  648.                         exit
  649.                     end
  650.                 end
  651.  
  652.                 /* locate standard includes */
  653.  
  654.                 if (SUGGEST_INCLUDE = "") then do
  655.  
  656.                     'EXPAND NAME="' || CONFIG.CFG_COMPILERFOLDER || '" VAR=SUGGEST_INCLUDE'
  657.  
  658.                     if (exists(SUGGEST_INCLUDE || 'include')) then
  659.  
  660.                         SUGGEST_INCLUDE = SUGGEST_INCLUDE || 'include'
  661.                 end
  662.  
  663.                 do until CONFIG.CFG_INCLUDE ~= ""
  664.  
  665.                     'REQUEST STRING BODY="' || STRING.sSTDHEADER || '" OLD="' || SUGGEST_INCLUDE || '" VAR=CONFIG.CFG_INCLUDE'
  666.  
  667.                     if ((CONFIG.CFG_INCLUDE ~= "") & (RC = 0)) then do
  668.  
  669.                         if (exists(CONFIG.CFG_INCLUDE) = 0) then do
  670.  
  671.                             'REQUEST PROBLEM="' || STRING.sSTDHEADERMISSING || '"'
  672.  
  673.                             CONFIG.CFG_INCLUDE = ""
  674.                         end
  675.                     end
  676.                     else do
  677.  
  678.                         'UNLOCK'
  679.  
  680.                         exit
  681.                     end
  682.                 end
  683.  
  684.                 /* locate OS includes */
  685.  
  686.                 do until CONFIG.CFG_NDK ~= ""
  687.  
  688.                     'REQUEST STRING BODY="' || STRING.sNDKHEADER || '" OLD="golded:add-ons/c++/ndk_39/include/include_h/" VAR=CONFIG.CFG_NDK'
  689.  
  690.                     if ((CONFIG.CFG_NDK ~= "") & (RC = 0)) then do
  691.  
  692.                         if (exists(CONFIG.CFG_NDK) = 0) then do
  693.  
  694.                             'REQUEST PROBLEM="' || STRING.sNDKHEADERMNISSING || '"'
  695.  
  696.                             CONFIG.CFG_NDK = ""
  697.                         end
  698.                     end
  699.                     else do
  700.  
  701.                         'UNLOCK'
  702.  
  703.                         exit
  704.                     end
  705.                 end
  706.  
  707.                 /* use built-in configuration for vbcc, gcc and sas/c, otherwise query user */
  708.  
  709.                 if ((CONFIG.CFG_SOFTWARE = "VBCC") | (CONFIG.CFG_SOFTWARE = "SAS/C") | (CONFIG.CFG_SOFTWARE = "SAS/C-GNUMAKE")) then do
  710.  
  711.                      CONFIG.CFG_COMPILE = SUGGEST_COMPILE
  712.                      CONFIG.CFG_LINK    = SUGGEST_LINK
  713.                 end
  714.                 else do
  715.  
  716.                     /* configure compile command */
  717.  
  718.                     'FIX VAR=SUGGEST_COMPILE'
  719.  
  720.                     do until CONFIG.CFG_COMPILE ~= ""
  721.  
  722.                         'REQUEST STRING BODY="' || STRING.sCOMPILE ||'" OLD="' || SUGGEST_COMPILE || '" VAR=CONFIG.CFG_COMPILE'
  723.  
  724.                         if (RC ~= 0) then do
  725.  
  726.                             'UNLOCK'
  727.  
  728.                             exit
  729.                         end
  730.                     end
  731.  
  732.                     /* configure link command */
  733.  
  734.                     'FIX VAR=SUGGEST_LINK'
  735.  
  736.                     do until CONFIG.CFG_LINK ~= ""
  737.  
  738.                         'REQUEST STRING BODY="' || STRING.sLINK || '" OLD="' || SUGGEST_LINK || '" VAR=CONFIG.CFG_LINK'
  739.  
  740.                         if (RC ~= 0) then do
  741.  
  742.                             'UNLOCK'
  743.  
  744.                             exit
  745.                         end
  746.                     end
  747.                 end
  748.  
  749.                 'EXPAND NAME="' || CONFIG.CFG_INCLUDE        || '" VAR=CONFIG.CFG_INCLUDE'
  750.                 'EXPAND NAME="' || CONFIG.CFG_COMPILERFOLDER || '" VAR=CONFIG.CFG_COMPILERFOLDER'
  751.                 'EXPAND NAME="' || CONFIG.CFG_NDK            || '" VAR=CONFIG.CFG_NDK'
  752.  
  753.                 call savecfg(CMODE)
  754.             end
  755.             else do
  756.  
  757.                 'UNLOCK'
  758.  
  759.                 exit
  760.             end
  761.         end
  762.  
  763.         /* fix quotes (for using these strings in a command line) */
  764.  
  765.         'FIX VAR=CONFIG.CFG_COMPILE'
  766.         'FIX VAR=CONFIG.CFG_LINK'
  767.         'FIX VAR=CONFIG.CFG_INCLUDE'
  768.         'FIX VAR=CONFIG.CFG_NDK'
  769.     end
  770.     else do
  771.  
  772.         'REQUEST PROBLEM="' || STRING.sNOTINSTALLED || " «" || CMODE || '»"'
  773.  
  774.         'UNLOCK'
  775.  
  776.         exit
  777.     end
  778.  
  779.     return
  780.  
  781. /* /// */
  782. /* /// "savecfg" */
  783.  
  784. savecfg: procedure expose CONFIG. STRING.
  785.  
  786.     parse upper arg CMODE
  787.  
  788.     R = open('CONFIG', CONFIG.CFG_CONFIG, 'WRITE')
  789.  
  790.     if (R = 0) then do
  791.  
  792.         'REQUEST PROBLEM="' || STRING.sCONFIGSAVEERR || '"'
  793.     end
  794.     else do
  795.  
  796.         'QUERY DATE VAR=DATE'
  797.  
  798.         R = writeln('CONFIG', "[SOFTWARE]")
  799.         R = writeln('CONFIG', CONFIG.CFG_SOFTWARE)
  800.         R = writeln('CONFIG', "[COMPILERFOLDER]")
  801.         R = writeln('CONFIG', CONFIG.CFG_COMPILERFOLDER)
  802.         R = writeln('CONFIG', "[INCLUDE]")
  803.         R = writeln('CONFIG', CONFIG.CFG_INCLUDE)
  804.         R = writeln('CONFIG', "[NDK]")
  805.         R = writeln('CONFIG', CONFIG.CFG_NDK)
  806.         R = writeln('CONFIG', "[COMPILE]")
  807.         R = writeln('CONFIG', CONFIG.CFG_COMPILE)
  808.         R = writeln('CONFIG', "[LINK]")
  809.         R = writeln('CONFIG', CONFIG.CFG_LINK)
  810.  
  811.         R = close('CONFIG')
  812.  
  813.         'REQUEST BODY="' || STRING.sCONFIGCREATED1 || "|«" || CMODE || "» " ||  STRING.sCONFIGCREATED2 || '" BUTTON="' || STRING.sOKEDIT || '"'
  814.  
  815.         if (RESULT = 2) then
  816.  
  817.             'OPEN NEW SMART NAME="' || CONFIG.CFG_CONFIG || '"'
  818.  
  819.         if ((RESULT ~= 1) | (RC ~= 0)) then do
  820.  
  821.             'UNLOCK'
  822.  
  823.             exit
  824.         end
  825.     end
  826.  
  827.     return
  828.  
  829. /* /// */
  830. /* /// "readoptions" */
  831.  
  832. readoptions: procedure expose CONFIG. STRING. PROJECTNAME OBJFOLDER GSTFILE
  833.  
  834.     /* read compiler-specific options file in project folder (if any exists) */
  835.  
  836.     parse upper arg SOFTWARE
  837.  
  838.     if ((SOFTWARE = "") | (SOFTWARE = "SAS/C") | (SOFTWARE = "SAS/C-GNUMAKE")) then do
  839.  
  840.         if (exists("scoptions")) then do
  841.  
  842.             if open('HANDLE', "scoptions", 'READ') then do
  843.  
  844.                 do until eof('HANDLE')
  845.  
  846.                     DATA = readln('HANDLE')
  847.  
  848.                     if (upper(left(DATA, 12)) = "PROGRAMNAME=") then do
  849.  
  850.                         PROJECTNAME = compress(substr(DATA, 13), '"')
  851.                     end
  852.                     else if (left(DATA, 11) = "OBJECTNAME=") then
  853.  
  854.                         OBJFOLDER = compress(substr(DATA, 12), '"')
  855.  
  856.                     else if (left(DATA, 18) = "GLOBALSYMBOLTABLE=") then
  857.  
  858.                         GSTFILE = compress(substr(DATA, 19), '"')
  859.                 end
  860.  
  861.                 R = close('HANDLE')
  862.             end
  863.         end
  864.     end
  865.  
  866.     return
  867.  
  868. /* /// */
  869. /* /// "saveoptions" */
  870.  
  871. saveoptions: procedure expose CONFIG. STRING. PROJECTNAME OBJFOLDER
  872.  
  873.     /* generate compiler-specific options file (only if none exists) */
  874.  
  875.     parse upper arg SOFTWARE
  876.  
  877.     if ((SOFTWARE = "SAS/C") | (SOFTWARE = "SAS/C-GNUMAKE")) then do
  878.  
  879.         if (exists("scoptions") = 0) then do
  880.  
  881.             R = open('HANDLE', "scoptions", 'WRITE')
  882.  
  883.             if (R = 0) then do
  884.  
  885.                 'REQUEST PROBLEM="' || STRING.sOPTIONSERR || '"'
  886.             end
  887.             else do
  888.  
  889.                 R = writeln('HANDLE', 'PROGRAMNAME="' || PROJECTNAME || '"')
  890.  
  891.                 if (OBJFOLDER ~= "") then
  892.  
  893.                     R = writeln('HANDLE', 'OBJECTNAME="'  || OBJFOLDER   || '"')
  894.  
  895.                 R = writeln('HANDLE', 'ERRORREXX')
  896.                 R = writeln('HANDLE', 'MODIFIED')
  897.                 R = writeln('HANDLE', 'NOLINK')
  898.                 R = writeln('HANDLE', 'IDENTIFIERLENGTH=80')
  899.                 R = writeln('HANDLE', 'NOICONS')
  900.                 R = writeln('HANDLE', 'VERBOSE')
  901.  
  902.                 R = close('HANDLE')
  903.             end
  904.         end
  905.     end
  906.     else if (SOFTWARE = "VBCC") then do
  907.  
  908.         if (exists("vbcc.options") = 0) then do
  909.  
  910.             R = open('HANDLE', "vbcc.options", 'WRITE')
  911.  
  912.             if (R = 0) then do
  913.  
  914.                 'REQUEST PROBLEM="' || STRING.sOPTIONSERR || '"'
  915.             end
  916.             else do
  917.  
  918.                 if (exists("env:vbcc.options")) then do
  919.  
  920.                     /* duplicate default configuration */
  921.  
  922.                     R = open('TEMPLATE', "env:vbcc.options", 'READ')
  923.  
  924.                     if (R = 0) then do
  925.  
  926.                         'REQUEST PROBLEM="' || STRING.sOPTIONSERR || '"'
  927.                     end
  928.                     else do
  929.  
  930.                         do until (eof('TEMPLATE'))
  931.  
  932.                             DATA = readln('TEMPLATE')
  933.  
  934.                             R = writeln('HANDLE', DATA)
  935.                         end
  936.  
  937.                         R = close('TEMPLATE')
  938.                     end
  939.                 end
  940.  
  941.                 R = close('HANDLE')
  942.             end
  943.         end
  944.     end
  945.     else if (SOFTWARE = "GCC") then do
  946.  
  947.         if (exists("gcc.options") = 0) then do
  948.  
  949.             R = open('HANDLE', "gcc.options", 'WRITE')
  950.  
  951.             if (R = 0) then do
  952.  
  953.                 'REQUEST PROBLEM="' || STRING.sOPTIONSERR || '"'
  954.             end
  955.             else do
  956.  
  957.                 if (exists("env:gcc.options")) then do
  958.  
  959.                     /* duplicate default configuration */
  960.  
  961.                     R = open('TEMPLATE', "env:gcc.options", 'READ')
  962.  
  963.                     if (R = 0) then do
  964.  
  965.                         'REQUEST PROBLEM="' || STRING.sOPTIONSERR || '"'
  966.                     end
  967.                     else do
  968.  
  969.                         do until (eof('TEMPLATE'))
  970.  
  971.                             DATA = readln('TEMPLATE')
  972.  
  973.                             R = writeln('HANDLE', DATA)
  974.                         end
  975.  
  976.                         R = close('TEMPLATE')
  977.                     end
  978.                 end
  979.  
  980.                 R = close('HANDLE')
  981.             end
  982.         end
  983.     end
  984.  
  985.     return
  986.  
  987. /* /// */
  988. /* /// "readmakefile" */
  989.  
  990. readmakefile: procedure expose CONFIG. STRING. PROJECTNAME
  991.  
  992.     parse upper arg SOFTWARE
  993.  
  994.     /* locate makefile */
  995.  
  996.     MAKEFILE = ""
  997.  
  998.     if ((SOFTWARE = "") | ((SOFTWARE ~= "SAS/C") & (SOFTWARE ~= "DICE"))) then do
  999.  
  1000.         if (exists("makefile")) then
  1001.  
  1002.             MAKEFILE = "makefile"
  1003.     end
  1004.  
  1005.     if (MAKEFILE = "") then do
  1006.  
  1007.         if ((SOFTWARE = "") | (SOFTWARE = "SAS/C")) then do
  1008.  
  1009.             if (exists("smakefile")) then
  1010.  
  1011.                 MAKEFILE = "smakefile"
  1012.         end
  1013.  
  1014.         if (MAKEFILE = "") then do
  1015.  
  1016.             if ((SOFTWARE = "") | (SOFTWARE = "DICE")) then do
  1017.  
  1018.                 if (exists("dmakefile")) then
  1019.  
  1020.                     MAKEFILE = "dmakefile"
  1021.             end
  1022.         end
  1023.     end
  1024.  
  1025.     /* try to locate executable name in makefile */
  1026.  
  1027.     if (MAKEFILE ~= "") then do
  1028.  
  1029.         if (open('HANDLE', MAKEFILE, 'READ') ~= 0) then do
  1030.  
  1031.             POS = 0
  1032.  
  1033.             do until (eof('HANDLE') | (PROJECTNAME ~= ""))
  1034.  
  1035.                 DATA = readln('HANDLE')
  1036.  
  1037.                 if (MAKEFILE = "smakefile") then do
  1038.  
  1039.                     if (pos("sc link to", DATA) ~= 0) then do
  1040.  
  1041.                         parse var DATA with 'sc' 'link' 'to' '"' PROJECTNAME '"' .
  1042.  
  1043.                         if (PROJECTNAME = "") then
  1044.  
  1045.                             parse var DATA with 'sc' 'link' 'to' PROJECTNAME .
  1046.                     end
  1047.                 end
  1048.                 else if (left(DATA, 3) = "EXE") then do
  1049.  
  1050.                     parse var DATA with 'EXE' '=' '"' PROJECTNAME '"'.
  1051.  
  1052.                     if (PROJECTNAME = "") then
  1053.  
  1054.                         parse var DATA with 'EXE' '=' PROJECTNAME .
  1055.                 end
  1056.             end
  1057.  
  1058.             R = close('HANDLE')
  1059.  
  1060.             PROJECTNAME = compress(PROJECTNAME, '"')
  1061.         end
  1062.     end
  1063.  
  1064.     return
  1065.  
  1066. /* /// */
  1067.